import allure

from test_pom.test4_八爪云接口自动化测试.base_api.base_api import BaseApi


class WarehouseApi(BaseApi):
    base_url = "http://api.wxorder.taover.com"

    @allure.step("创建仓库")
    def create_warehouse(self, data):
        create_warehouse_uel = f"{self.base_url}/v1/wxorderware"
        req = {
            "method": "post",
            "url": create_warehouse_uel,
            "json": data,
            "headers": {"Authorization": self.get_token()}
        }
        res = self.send_api(req)
        return res

    @allure.step("搜索仓库")
    def search_warehouse(self, data):
        search_url = f"{self.base_url}/v1/wxorderware"
        req = {
            "method": "get",
            "url": search_url,
            "headers": {"Authorization": self.get_token()},
            "params": data
        }
        res = self.send_api(req)
        return res

    @allure.step("删除仓库")
    def delete_warehouse(self, ssid):
        delete_url = f"{self.base_url}/v1/wxorderware/{ssid}"
        req = {
            "method": "delete",
            "url": delete_url,
            "headers": {"Authorization": self.get_token()}
        }
        res = self.send_api(req)
        return res


if __name__ == '__main__':
    print(WarehouseApi().search_warehouse())
